import request from '@/utils/request'

/**
 * 获取代取分类列表
 */
export function getCategoryList() {
  return request.get('/pickup/category/list')
}

/**
 * 创建代取订单
 * @param {Object} data - 订单数据
 */
export function createPickupOrder(data) {
  return request.post('/pickup/order/create', data)
}

/**
 * 获取代取订单列表
 * @param {Object} params - 查询参数
 */
export function getPickupOrderPage(params) {
  return request.get('/pickup/order/page', params)
}

/**
 * 获取可接订单列表
 * @param {Object} params - 查询参数
 */
export function getAvailableOrders(params) {
  return request.get('/pickup/order/available', params)
}

/**
 * 获取订单详情
 * @param {String} id - 订单ID
 */
export function getPickupOrderDetail(id) {
  return request.get(`/pickup/order/${id}`)
}

/**
 * 接单
 * @param {String} id - 订单ID
 */
export function acceptOrder(id) {
  return request.post(`/pickup/order/${id}/accept`)
}

/**
 * 确认取件
 * @param {String} id - 订单ID
 * @param {Object} data - 取件数据（照片等）
 */
export function confirmPickup(id, data) {
  return request.post(`/pickup/order/${id}/pickup`, data)
}

/**
 * 确认送达
 * @param {String} id - 订单ID
 * @param {Object} data - 送达数据（照片等）
 */
export function confirmDeliver(id, data) {
  return request.post(`/pickup/order/${id}/deliver`, data)
}

/**
 * 确认收货
 * @param {String} id - 订单ID
 */
export function confirmReceive(id) {
  return request.post(`/pickup/order/${id}/confirm`)
}

/**
 * 取消订单
 * @param {String} id - 订单ID
 * @param {String} reason - 取消原因
 */
export function cancelPickupOrder(id, reason) {
  return request.post(`/pickup/order/${id}/cancel`, null, { reason })
}

/**
 * 支付订单
 * @param {String} id - 订单ID
 */
export function payPickupOrder(id) {
  return request.post(`/pickup/order/${id}/pay`)
}

/**
 * 获取收益统计
 */
export function getSettlementStatistics() {
  return request.get('/pickup/settlement/statistics')
}

/**
 * 获取结算记录
 * @param {Object} params - 查询参数
 */
export function getSettlementRecords(params) {
  return request.get('/pickup/settlement/records', params)
}

/**
 * 申请结算（接单人）
 * @param {String} id - 订单ID
 * @param {Object} data - 结算数据
 */
export function applySettlement(id, data) {
  return request.post(`/pickup/order/${id}/apply-settlement`, data)
}

/**
 * 获取结算信息（商家查看）
 * @param {String} id - 订单ID
 */
export function getSettlementInfo(id) {
  return request.get(`/pickup/settlement/info/${id}`)
}

/**
 * 商家确认结算
 * @param {String} id - 订单ID
 */
export function settleOrder(id) {
  return request.post(`/pickup/settlement/settle/${id}`)
}

/**
 * 获取平台配置
 */
export function getPickupConfig() {
  return request.get('/pickup/config')
}

